//
//  SpeclalLineCell.m
//  Commerce
//
//  Created by xiaofeifei on 15/2/16.
//  Copyright (c) 2015年 fei. All rights reserved.
//

#import "SpeclalLineCell.h"
#import "GlobalData.h"

@implementation SpeclalLineCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)configUIWithData:(NSDictionary *)data{
    if (![data[@"HeadPic"] isEqual:[NSNull null]]) {
        NSString *path = [[GlobalData getStringValue:data[@"HeadPic"]] stringByReplacingOccurrencesOfString:@"~" withString:@""];
        NSString *imgUrl = [NSString stringWithFormat:@"%@%@",URL_ROOT_PIC,path];
        [_Img sd_setImageWithURL:[NSURL URLWithString:imgUrl] placeholderImage:[UIImage imageNamed:@""]];
    }
    _nameLabel.text = [GlobalData getStringValue:data[@"CompanyName"]];
    _telLabel.text = [GlobalData getStringValue:data[@"CompanyTel"]];
    _addressLabel.text = [GlobalData getStringValue:data[@"Address"]];
    _viewNumLabel.text = [NSString stringWithFormat:@"浏览次数：%@",[GlobalData getStringValue:data[@"ViweNum"]]];
    [self paretoImgs:data];
}

- (void)paretoImgs:(NSDictionary *)dic{
    NSMutableArray *array = [[NSMutableArray alloc] init];
    if ([dic[@"isvip"] integerValue] == 1) {
        [array addObject:@"isvip"];
    }
    if ([dic[@"VipLevel"] integerValue] >= 1) {
        [array addObject:@"VIP"];
    }
    if ([dic[@"TagA"] integerValue] == 1) {
        [array addObject:@"TagA"];
    }
    if ([dic[@"TagB"] integerValue] == 1) {
        [array addObject:@"TagB"];
    }
    if ([dic[@"TagC"] integerValue] == 1) {
        [array addObject:@"TagC"];
    }
    if ([dic[@"TagD"] integerValue] == 1) {
        [array addObject:@"TagD"];
    }
    if ([dic[@"TagE"] integerValue] == 1) {
        [array addObject:@"TagE"];
    }
    if ([dic[@"IsSpec"] integerValue] == 1) {
        [array addObject:@"IsSpec"];
    }
   
    //拍照
    float width = 15;
    float height = 20;
    float origX = 10;
    float origY = (_ImgsScroll.frame.size.height-height)/2.0;
    float gapX = 10;
    for (int i=0; i<array.count; i++) {
        NSLog(@"%f",origX+(gapX+width)*i);
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(origX+(gapX+width)*i, origY, width, height)];
        imageView.image =[UIImage imageNamed:array[i]];
        imageView.layer.masksToBounds = YES;
        imageView.layer.cornerRadius = 3.0;
        
        // 内容模式
        imageView.clipsToBounds = YES;
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        
        [_ImgsScroll addSubview:imageView];
        
    }
    _ImgsScroll.contentSize = CGSizeMake(origX+(gapX+width)*[array count], _ImgsScroll.frame.size.height);
}


@end
